import numpy as np
import base64
import requests

images = np.load(r'G:\face_card.pkg', allow_pickle=True)
print(len(images))

url = 'http://192.168.1.160:11180/face/v1/framework/face_image/repository/picture/synchronized/global'
repository_id = 181
cluster_id = 'OK_1545115071'

gIndex = 0
for image in images:
	gIndex += 1
	(person_id, name) = image['img_full_path'].split('\\')[-1].split('_')[3:5]
	print(gIndex, person_id, name)
	picture_image_content_base64 = base64.b64encode(image['bytes']).decode()

	data = {
		"options": {
			"force_build_index": False,
			"max_faces_allowed": -1
		},
		"repository_id": repository_id,
		"person_id": person_id,
		"name": name,
		"picture_image_content_base64": picture_image_content_base64,
		"cluster_id": cluster_id
	}
	print(requests.post(url=url, json=data).text[:20])
